package net.wangxl.mvc;

import net.wangxl.dao.data1.UserMapper;
import net.wangxl.dao.data2.ProductMapper;
import net.wangxl.domain.Product;
import net.wangxl.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class ResetFulController {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ProductMapper productMapper;

    @GetMapping("/{id:\\d+}")
    public String get(@PathVariable("id") Integer id){
        if(id == 1){
            return "皮卡丘";
        }
        return "空";
    }

    @GetMapping("/")
    public String get(@RequestParam("name") String name){
        if(name .equals("小霞") ){
            return "可达鸭";
        }
        return "空";
    }
    
    @GetMapping("/test")
    public void test(){
        User user = userMapper.selectByPrimaryKey(1);

        Product product = productMapper.selectByPrimaryKey(1);

        System.out.println(user);
        System.out.println(product);
    }
}
